package servlets;

import java.io.IOException;
import java.util.List;

import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import model.Book;

import dao.BookDao;
import dao.BookDaoImpl;
import dao.DaoFactory;

public class BookList extends HttpServlet {	
	
	private static final long serialVersionUID = 1L;
	
	final BookDao bookDao = DaoFactory.getInstance().getBookDao();
	
	public void doGet(HttpServletRequest request, HttpServletResponse response)	throws ServletException, IOException {
		List<Book> collection = bookDao.list();
		request.setAttribute("books", collection);
		RequestDispatcher dispatcher = getServletContext().getRequestDispatcher("/jsp/list.jsp");
		dispatcher.forward(request, response);		
	}
}
